<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Jumper documentation</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Jumper(v1.8.1)</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>


<h2>Modules</h2>
<ul>
  <li><a href="../modules/jumper.core.bheap.html">jumper.core.bheap</a></li>
  <li><a href="../modules/jumper.core.heuristics.html">jumper.core.heuristics</a></li>
  <li><a href="../modules/jumper.core.node.html">jumper.core.node</a></li>
  <li><a href="../modules/jumper.core.path.html">jumper.core.path</a></li>
  <li><a href="../modules/jumper.grid.html">jumper.grid</a></li>
  <li><a href="../modules/jumper.grid.html">jumper.grid</a></li>
  <li><strong>jumper.pathfinder</strong></li>
</ul>
<h2>Scripts</h2>
<ul>
  <li><a href="../scripts/jumper.search.astar.html">jumper.search.astar</a></li>
  <li><a href="../scripts/jumper.search.bfs.html">jumper.search.bfs</a></li>
  <li><a href="../scripts/jumper.search.dfs.html">jumper.search.dfs</a></li>
  <li><a href="../scripts/jumper.search.dijkstra.html">jumper.search.dijkstra</a></li>
  <li><a href="../scripts/jumper.search.jps.html">jumper.search.jps</a></li>
  <li><a href="../scripts/jumper.search.thetastar.html">jumper.search.thetastar</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>jumper.pathfinder</code></h1>

<p><strong>The <strong>pathfinder</strong> class API</strong>.</p>
<p> Implementation of the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  class.</p>
    <h3>Usage:</h3>
    <ul>
        <pre class="example">-- Usage Example
-- First, set a collision map
local map = {
	{0,1,0,1,0},
	{0,1,0,1,0},
	{0,1,1,1,0},
	{0,0,0,0,0},
}
-- Value for walkable tiles
local walkable = 0

-- Library setup
local Grid = require (&quot;jumper.grid&quot;) -- The grid class
local Pathfinder = require (&quot;jumper.pathfinder&quot;) -- The pathfinder lass

-- Creates a grid object
local grid = Grid(map)
-- Creates a pathfinder object using Jump Point Search
local myFinder = Pathfinder(grid, &apos;JPS&apos;, walkable)

-- Define start and goal locations coordinates
local startx, starty = 1,1
local endx, endy = 5,1

-- Calculates the path, and its length
local path, length = myFinder:getPath(startx, starty, endx, endy)
if path then
  print((&apos;Path found! Length: %.2f&apos;):format(length))
	for node, count in path:iter() do
	  print((&apos;Step: %d - x: %d - y: %d&apos;):format(count, node.x, node.y))
	end
end

--&gt; Output:
--&gt; Path found! Length: 8.83
--&gt; Step: 1 - x: 1 - y: 1
--&gt; Step: 2 - x: 1 - y: 3
--&gt; Step: 3 - x: 2 - y: 4
--&gt; Step: 4 - x: 4 - y: 4
--&gt; Step: 5 - x: 5 - y: 3
--&gt; Step: 6 - x: 5 - y: 1
</pre>
    </ul>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: 2012-2013</li>
        <li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li>
        <li><strong>Author</strong>: Roland Yonaba</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#pathfinder:new">pathfinder:new&nbsp;(grid[, finderName[, walkable]])</a></td>
	<td class="summary">Inits a new <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setGrid">pathfinder:setGrid&nbsp;(grid)</a></td>
	<td class="summary">Sets a <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getGrid">pathfinder:getGrid&nbsp;()</a></td>
	<td class="summary">Returns the <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setWalkable">pathfinder:setWalkable&nbsp;(walkable)</a></td>
	<td class="summary">Sets the <code>walkable</code> value or function.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getWalkable">pathfinder:getWalkable&nbsp;()</a></td>
	<td class="summary">Gets the <code>walkable</code> value or function.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setFinder">pathfinder:setFinder&nbsp;(finderName)</a></td>
	<td class="summary">Sets a finder.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getFinder">pathfinder:getFinder&nbsp;()</a></td>
	<td class="summary">Gets the name of the finder being used.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getFinders">pathfinder:getFinders&nbsp;()</a></td>
	<td class="summary">Gets the list of all available finders names.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setHeuristic">pathfinder:setHeuristic&nbsp;(heuristic)</a></td>
	<td class="summary">Set a heuristic.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getHeuristic">pathfinder:getHeuristic&nbsp;()</a></td>
	<td class="summary">Gets the heuristic used.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getHeuristics">pathfinder:getHeuristics&nbsp;()</a></td>
	<td class="summary">Gets the list of all available heuristics.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:setMode">pathfinder:setMode&nbsp;(mode)</a></td>
	<td class="summary">Changes the search mode.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getMode">pathfinder:getMode&nbsp;()</a></td>
	<td class="summary">Gets the search mode.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getModes">pathfinder:getModes&nbsp;()</a></td>
	<td class="summary">Gets the list of all available search modes.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:version">pathfinder:version&nbsp;()</a></td>
	<td class="summary">Returns version and release date.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#pathfinder:getPath">pathfinder:getPath&nbsp;(startX, startY, endX, endY[, tunnel])</a></td>
	<td class="summary">Calculates a path.</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#pathfinder">pathfinder</a></td>
	<td class="summary">The <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  class</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "pathfinder:new"></a>
    <strong>pathfinder:new&nbsp;(grid[, finderName[, walkable]])</strong>
    </dt>
    <dd>
    Inits a new <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">grid</span>
        <span class="types"><a class="type" href="../modules/jumper.pathfinder.html#jumper.grid">grid</a></span>
       a <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object</li>
      <li><span class="parameter">finderName</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       the name of the <code>finder</code> (search algorithm) to be used for further searches.
 Defaults to <code>ASTAR</code> when not given. Use <a href="../modules/jumper.pathfinder.html#pathfinder:getFinders">pathfinder:getFinders</a> to get the full list of available finders..</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
       the value for walkable nodes on the passed-in map array.
 If this parameter is a function, it should be prototyped as <code>f(value)</code>, returning a boolean:
 <code>true</code> when value matches a <em>walkable</em> node, <code>false</code> otherwise.</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a></span>
        a new <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setGrid"></a>
    <strong>pathfinder:setGrid&nbsp;(grid)</strong>
    </dt>
    <dd>
    Sets a <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object.  Defines the <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  on which the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  will make path searches.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">grid</span>
        <span class="types"><a class="type" href="../modules/jumper.pathfinder.html#jumper.grid">grid</a></span>
       a <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object</li>
    </ul>





</dd>
    <dt>
    <a name = "pathfinder:getGrid"></a>
    <strong>pathfinder:getGrid&nbsp;()</strong>
    </dt>
    <dd>
    Returns the <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object.  Returns a reference to the internal <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object used by the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/jumper.pathfinder.html#jumper.grid">grid</a></span>
        the <a href="../modules/jumper.pathfinder.html#jumper.grid">grid</a>  object
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setWalkable"></a>
    <strong>pathfinder:setWalkable&nbsp;(walkable)</strong>
    </dt>
    <dd>
    Sets the <code>walkable</code> value or function.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
       the value for walkable nodes on the passed-in map array.
 If this parameter is a function, it should be prototyped as <code>f(value)</code>, returning a boolean:
 <code>true</code> when value matches a <em>walkable</em> node, <code>false</code> otherwise.</li>
    </ul>





</dd>
    <dt>
    <a name = "pathfinder:getWalkable"></a>
    <strong>pathfinder:getWalkable&nbsp;()</strong>
    </dt>
    <dd>
    Gets the <code>walkable</code> value or function.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
        the <code>walkable</code> previously set
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setFinder"></a>
    <strong>pathfinder:setFinder&nbsp;(finderName)</strong>
    </dt>
    <dd>
    Sets a finder.  The finder refers to the search algorithm used by the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object.
 The default finder is <code>ASTAR</code>. Use <a href="../modules/jumper.pathfinder.html#pathfinder:getFinders">pathfinder:getFinders</a> to get the list of available finders.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">finderName</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       the name of the finder to be used for further searches.</li>
    </ul>



    <h3>see also:</h3>
    <ul>
         <a href="../modules/jumper.pathfinder.html#pathfinder:getFinders">pathfinder:getFinders</a>
    </ul>


</dd>
    <dt>
    <a name = "pathfinder:getFinder"></a>
    <strong>pathfinder:getFinder&nbsp;()</strong>
    </dt>
    <dd>
    Gets the name of the finder being used.  The finder refers to the search algorithm used by the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        the name of the finder to be used for further searches.
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:getFinders"></a>
    <strong>pathfinder:getFinders&nbsp;()</strong>
    </dt>
    <dd>
    Gets the list of all available finders names.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{string,...}</span></span>
        array of finders names.
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setHeuristic"></a>
    <strong>pathfinder:setHeuristic&nbsp;(heuristic)</strong>
    </dt>
    <dd>
    Set a heuristic.  This is a function internally used by the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  to get the optimal path during a search.
 Use <a href="../modules/jumper.pathfinder.html#pathfinder:getHeuristics">pathfinder:getHeuristics</a> to get the list of all available heuristics. One can also defined
 his own heuristic function.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">heuristic</span>
        <span class="types"><span class="type">function</span> or <a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       a heuristic function, prototyped as <code>f(dx,dy)</code> or a string.</li>
    </ul>



    <h3>see also:</h3>
    <ul>
         <a href="../modules/jumper.pathfinder.html#pathfinder:getHeuristics">pathfinder:getHeuristics</a>
    </ul>


</dd>
    <dt>
    <a name = "pathfinder:getHeuristic"></a>
    <strong>pathfinder:getHeuristic&nbsp;()</strong>
    </dt>
    <dd>
    Gets the heuristic used.  Returns the function itself.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">function</span></span>
        the heuristic function being used by the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:getHeuristics"></a>
    <strong>pathfinder:getHeuristics&nbsp;()</strong>
    </dt>
    <dd>
    Gets the list of all available heuristics.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{string,...}</span></span>
        array of heuristic names.
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:setMode"></a>
    <strong>pathfinder:setMode&nbsp;(mode)</strong>
    </dt>
    <dd>
    Changes the search mode.  Defines a new search mode for the <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  object.
 The default search mode is <code>DIAGONAL</code>, which implies 8-possible directions when moving (north, south, east, west and diagonals).
 In <code>ORTHOGONAL</code> mode, only 4-directions are allowed (north, south, east and west).
 Use <a href="../modules/jumper.pathfinder.html#pathfinder:getModes">pathfinder:getModes</a> to get the list of all available search modes.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">mode</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       the new search mode.</li>
    </ul>



    <h3>see also:</h3>
    <ul>
         <a href="../modules/jumper.pathfinder.html#pathfinder:getModes">pathfinder:getModes</a>
    </ul>


</dd>
    <dt>
    <a name = "pathfinder:getMode"></a>
    <strong>pathfinder:getMode&nbsp;()</strong>
    </dt>
    <dd>
    Gets the search mode.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        the current search mode
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:getModes"></a>
    <strong>pathfinder:getModes&nbsp;()</strong>
    </dt>
    <dd>
    Gets the list of all available search modes.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{string,...}</span></span>
        array of search modes.
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:version"></a>
    <strong>pathfinder:version&nbsp;()</strong>
    </dt>
    <dd>
    Returns version and release date.


    <h3>Returns:</h3>
    <ol>
        <li>
          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        the version of the current implementation</li>
        <li>
          <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        the release of the current implementation</li>
    </ol>




</dd>
    <dt>
    <a name = "pathfinder:getPath"></a>
    <strong>pathfinder:getPath&nbsp;(startX, startY, endX, endY[, tunnel])</strong>
    </dt>
    <dd>
    Calculates a path.  Returns the path from location <code>&lt;startX, startY&gt;</code> to location <code>&lt;endX, endY&gt;</code>.
 Both locations must exist on the collision map.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">startX</span>
        <span class="types"><span class="type">number</span></span>
       the x-coordinate for the starting location</li>
      <li><span class="parameter">startY</span>
        <span class="types"><span class="type">number</span></span>
       the y-coordinate for the starting location</li>
      <li><span class="parameter">endX</span>
        <span class="types"><span class="type">number</span></span>
       the x-coordinate for the goal location</li>
      <li><span class="parameter">endY</span>
        <span class="types"><span class="type">number</span></span>
       the y-coordinate for the goal location</li>
      <li><span class="parameter">tunnel</span>
        <span class="types"><span class="type">bool</span></span>
       Whether or not the pathfinder can tunnel though walls diagonally (not compatible with <code>Jump Point Search</code>)</li>
    </ul>

    <h3>Returns:</h3>
    <ol>
        <li>
          <span class="types"><span class="type">{node,...}</span></span>
        a path (array of <code>nodes</code>) when found, otherwise <code>nil</code></li>
        <li>
          <span class="types"><span class="type">number</span></span>
        the path length when found, <code>0</code> otherwise</li>
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>

    <dl class="function">
    <dt>
    <a name = "pathfinder"></a>
    <strong>pathfinder</strong>
    </dt>
    <dd>
    The <a href="../modules/jumper.pathfinder.html#jumper.pathfinder">pathfinder</a>  class






</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
